define(function (echarts) {

    var self,
        doc = document,
        app = win.app,
        layui = win.layui,
        element,
        table,
        table_where = {},
        cols = [],
        moduleName = '网点活跃度',
        cols=[[
            {field: 'ROW_ID',title: "",width: 60, fixed: 'left'}
            ,{field: 'GWAK010',title: '销售渠道',width: 150, fixed: 'left'}
            ,{field: 'GWAOL003',title: '品类',width: 80,sort:true,search:'default'}
            ,{field: 'REALVAL',title: '实际销售额',width: 80,sort:true,search:'default'}
        ]];
    ;

    app.newModule({
        init: function () {
            self = this;
            self._super({
                _tag: 'hyd-info'
            }, win);

        },

        initTable: function (data) {
            layui.use(['table'], function () {
                table = layui.table;
                table.render({
                    elem: app.getByid(doc, 'hyd_detail'),
                    title: moduleName + '信息表',
                    id: 'hyd_detail',
                    defaultToolbar: [],
                    height: 'full',
                    cols: cols,
                    data:data,
                    loading: true,
                    page: true,
                    where: table_where
                });

            });

        },
        _call: function (obj) {
            console.log(obj)
            var data = obj.item.data;
            app.ajax({
                xurl: '/bb/wdhyd/getInfo',
                xdata: {
                    GWAK010:data.GWAK010,
                    startDate:obj.startDate,
                    endDate:obj.endDate
                },
                cb: function (res) {
                    if (res.ok) {
                        var d = res.data.data;
                        d.forEach(function (item, index) {
                            item.ROW_ID=index+1;
                            item.GWAK010=data.GWAK010;
                        })
                        self.initTable(d);
                    }
                }
            });
        },
        _ready: function () {
            this._super({
            });

            new Vue({
                el: document.getElementById('hyd-info'),
                data: {},
                methods: {
                    cancel: function () {
                        layer.close(layer.index);
                    }
                },
                watch: {},
                created: function () {
                    self._setEleIsReady('hyd-info');
                }
            });

        },
        _lazy: function () {
            this._super();
        }
    });

});